home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / HyperGeometric.h,v < prev    next >
Text File  |  1989-05-04  |  3KB  |  124 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.35.06;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.49.58;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     88.09.18.16.42.09;  author grunwald;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 3.2
  30. log
  31. @Start using Gnu library heaps for schedulers
  32. @
  33. text
  34. @// This may look like C code, but it is really -*- C++ -*-
  35. /* 
  36. Copyright (C) 1988 Free Software Foundation
  37.     written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  38.  
  39. This file is part of GNU CC.
  40.  
  41. GNU CC is distributed in the hope that it will be useful,
  42. but WITHOUT ANY WARRANTY.  No author or distributor
  43. accepts responsibility to anyone for the consequences of using it
  44. or for whether it serves any particular purpose or works at all,
  45. unless he says so in writing.  Refer to the GNU CC General Public
  46. License for full details.
  47.  
  48. Everyone is granted permission to copy, modify and redistribute
  49. GNU CC, but only under the conditions described in the
  50. GNU CC General Public License.   A copy of this license is
  51. supposed to have been given to you along with GNU CC so you
  52. can know your rights and responsibilities.  It should be in a
  53. file named COPYING.  Among other things, the copyright notice
  54. and this notice must be preserved on all copies.  
  55. */
  56. #ifndef _HyperGeometric_h
  57. #define _HyperGeometric_h 
  58.  
  59. #include <Random.h>
  60.  
  61. class HyperGeometric: public Random {
  62.     double pMean;
  63.     double pVariance;
  64.     double pP;
  65.     void setState();
  66.  
  67. public:
  68.     HyperGeometric(double mean, double variance, RNG *gen);
  69.  
  70.     double mean();
  71.     double mean(double x);
  72.     double variance();
  73.     double variance(double x);
  74.  
  75.     virtual double operator()();
  76. };
  77.  
  78. //#ifdef __OPTIMIZE__
  79.  
  80. inline void HyperGeometric::setState() {
  81.   double z = pVariance / (pMean * pMean);
  82.   pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 )));
  83. }
  84.  
  85. inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen)
  86. : (gen) {
  87.   pMean = mean; pVariance = variance;
  88.   setState();
  89. }
  90.  
  91. inline double HyperGeometric::mean() { return pMean; };
  92.  
  93. inline double HyperGeometric::mean(double x) {
  94.   double t = pMean; pMean = x;
  95.   setState(); return t;
  96. }
  97.  
  98. inline double HyperGeometric::variance() { return pVariance; }
  99.  
  100. inline double HyperGeometric::variance(double x) {
  101.   double t = pVariance; pVariance = x;
  102.   setState(); return t;
  103. }
  104.  
  105. //#endif
  106. #endif
  107. @
  108.  
  109.  
  110. 3.1
  111. log
  112. @Steay version
  113. @
  114. text
  115. @@
  116.  
  117.  
  118. 1.1
  119. log
  120. @Initial revision
  121. @
  122. text
  123. @@
  124.